package com.example.demo.web.utils;

import com.csvreader.CsvReader;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;

/**
 * Created by kong on 2017/9/13.
 */
public class CSVFile {
    public static void main(String[] args) {
        readCsvFile();
    }

    private static void readCsvFile() {
        try {
            CsvReader csvReader = new CsvReader("E:\\workhistory\\springcloud\\UserProvider\\CSV.csv", ',', Charset.forName("GBK"));
            csvReader.readHeaders();
            while(csvReader.readRecord()){
                System.out.println(csvReader.getRawRecord());
                System.out.println(csvReader.get("username"));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
